using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace Renderer.DataStructures
{
    /// <summary>
    /// This class is container of all objects(for now only triangles are used) in 3D space
    /// </summary>
    [Serializable]
    class Scene
    {
        private Vector3D cameraPosition;
        private Vector3D cameraDirection;
        
        /// <summary>
        /// Horizontal field of view - angel between left and right sides of the view area
        /// of the camera
        /// </summary>
        public readonly double FOV = Math.PI / 2; 
        
        /// <summary>
        /// Vector which is perpendicular to the plane in which camera is located
        /// </summary>
        public readonly Vector3D ToUpOfCamera = new Vector3D(0,0,1);            
        
        /// <summary>
        /// All triangles of the scene which do emit light
        /// </summary>        
        private IList<Triangle> lightTriangles = new List<Triangle>();
        
        /// <summary>
        /// All triangles of the scene which don't emit light
        /// </summary>
        private IList<Triangle> triangles = new List<Triangle>();

        public Vector3D CameraPosition
        {
            get { return cameraPosition; }
            set { cameraPosition = value; }
        }

        public Vector3D CameraDirection
        {
            get { return cameraDirection; }
            set { cameraDirection = value.Normalize(); }
        }

        public IList<Triangle> Triangles
        {
            get { return triangles; }
        }

        public IList<Triangle> LightTriangles
        {
            get { return lightTriangles; }
        }

        public Scene()
        {
            
        }
        
        public Scene Join(Scene s)
        {                        
            foreach (Triangle triangle in s.Triangles)
            {
                triangles.Add(triangle);
            }            
            foreach (Triangle triangle in s.LightTriangles)
            {
                lightTriangles.Add(triangle);
            }
            return this;
        }
    }
}
